package com.oa.hyperion.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oa.hyperion.entity.Post;
import com.oa.hyperion.repository.Base.DepartmentMapper;
import com.oa.hyperion.repository.Base.PostMapper;
import com.oa.hyperion.service.PostService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements PostService {

    @Resource
    private PostMapper postMapper;

    @Resource
    private DepartmentMapper departmentMapper;

    @Override
    public List<Post> getPostWithDepartment() {
        //获取post列表
        List<Post> list=postMapper.selectList(new QueryWrapper<>());
        //遍历list 获取部门属性
        for(Post p:list){
            p.setDepart(departmentMapper.selectById(p.getDepartment()));
        }
        return list;

    }
}
